package com.ly.web.controller.erp;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.BidEntity;
import com.ly.heart.service.IBidService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

/**
 * 标书管理，审批该标书是否可用Controller
 *
 * @author cxl
 * @date 2024-05-14
 */
@Api(value = "Bid", tags = "标书管理，审批该标书是否可用")
@RestController
@RequestMapping("/heart/Bid")
public class BidController extends BaseController
{
    @Resource
    private IBidService bidService;

//    /**
//     * 查询标书管理，审批该标书是否可用列表
//     */
//    @PreAuthorize("@ss.hasPermi('heart:Bid:list')")
//    @GetMapping("/list")
//    @ApiOperation("查询标书管理")
//    public TableDataInfo list(BidEntity bidEntity)
//    {
//        startPage();
//        List<BidEntity> list = bidService.selectBidEntityList(bidEntity);
//        return getDataTable(list);
//    }

    /**
     * 导出标书管理，审批该标书是否可用列表
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:export')")
    @Log(title = "标书管理，审批该标书是否可用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出标书管理")
    public void export(HttpServletResponse response, BidEntity bidEntity)
    {
        List<BidEntity> list = bidService.selectBidEntityList(bidEntity);
        ExcelUtil<BidEntity> util = new ExcelUtil<BidEntity>(BidEntity.class);
        util.exportExcel(list, "标书管理，审批该标书是否可用数据");
    }

    /**
     * 标书管理列表
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:list')")
    @PostMapping("/page")
    @ApiOperation("标书管理列表")
    public AjaxResult selectBidList(@RequestBody BidEntity bidEntity)
    {
        return bidService.selectBidList(bidEntity);
    }

    /**
     * 获取标书管理，审批该标书是否可用详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取标书管理")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
//        return AjaxResult.success(bidService.selectBidEntityById(id));
        return AjaxResult.success(bidService.selectBidVoById(id));
    }

    /**
     * 新增标书管理，审批该标书是否可用
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:add')")
    @Log(title = "标书管理，审批该标书是否可用", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增标书管理")
    public AjaxResult add(@RequestBody BidEntity bidEntity)
    {
        return toAjax(bidService.insertBidEntity(bidEntity));
    }

    /**
     * 修改标书管理，审批该标书是否可用
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:edit')")
    @Log(title = "标书管理，审批该标书是否可用", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改标书管理")
    public AjaxResult edit(@RequestBody BidEntity bidEntity)
    {
        return toAjax(bidService.updateBidEntity(bidEntity));
    }

    /**
     * 删除标书管理，审批该标书是否可用
     */
    @PreAuthorize("@ss.hasPermi('heart:Bid:remove')")
    @Log(title = "标书管理，审批该标书是否可用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除标书管理")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bidService.deleteBidEntityByIds(ids));
    }
}
